package net.fdukedom.epicurus.domain.install;

import net.fdukedom.epicurus.domain.util.UserHelper;
import net.fdukedom.epicurus.domain.entity.User;

/**
 * Handles installation routine.
 *
 * @author Dmitry Y. Kochelaev
 */
public class InstallHelper {

    /**
     * The only instance of the class.
     */
    private static InstallHelper instance = new InstallHelper();

    /**
     * Default constructor.
     */
    private InstallHelper() {
        //this is an utility class only one instance is allowed
    }

    /**
     * Returns the only instance of the class.
     *
     * @return the only instance of the class
     */
    public static InstallHelper getInstance() {
        return instance;
    }

    /**
     * Installs epicurus. Creates users table and root account.
     *
     * @param rootLogin login of root user
     * @param rootEmail email of root user
     * @param rootPassword password of root user
     */
    public void install(String rootLogin, String rootEmail, String rootPassword) {
        //Create root account and users table
        User rootUser = new User(rootLogin, rootEmail, rootPassword);
        rootUser.setIsRoot(true);
        UserHelper.getInstance().saveUser(rootUser);
    }
}
